package org.example;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class ShoppingCartUtil {

    public static BigDecimal discountEveryHundred(BigDecimal total, BigDecimal discountAmount) {
        // 获取完整满100的次数
        int hundredCount = total.divide(new BigDecimal("100"), RoundingMode.FLOOR).intValue();
        // 计算总减免金额
        BigDecimal discount = discountAmount.multiply(BigDecimal.valueOf(hundredCount));
        // 返回原价减去减免金额
        return total.subtract(discount);
    }

    public static void main(String[] args) {
        BigDecimal input = new BigDecimal("648.0");
        BigDecimal discountAmount = new BigDecimal("10");

        BigDecimal result = discountEveryHundred(input, discountAmount);

        System.out.println(result);  // 输出：588.0
    }

}
